package com.ki.erp.service;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;

public class ParameterizedTypeExample {
    public List<String> stringList;

    public static void main(String[] args) throws Exception {
        ParameterizedTypeExample example = new ParameterizedTypeExample();
        Type fieldType = example.getClass().getField("stringList").getGenericType();

        if (fieldType instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) fieldType;

            // 获取原始类型
            Type rawType = parameterizedType.getRawType();
            System.out.println("Raw type: " + rawType);

            // 获取实际类型参数
            Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
            for (Type type : actualTypeArguments) {
                System.out.println("Actual type argument: " + type);
            }
        }
    }
}
